package com.lyy.lottery.common.util;

import cn.hutool.captcha.LineCaptcha;
import cn.hutool.captcha.generator.RandomGenerator;

public class CaptchaUtil {
    //生成随机验证码
    public static String getCaptcha(int length){
        //自定义纯数字验证码（随机4位数，可重复）
        RandomGenerator randomGenerator=new RandomGenerator("0123456789",length);
        LineCaptcha captcha= cn.hutool.captcha.CaptchaUtil.createLineCaptcha(200,100);
        captcha.setGenerator(randomGenerator);
        //重新生成code
        captcha.createCode();
        return captcha.getCode();
    }
}
